toastTime = 0
toast = (message, level, time)->
    clearTimeout(toastTime)
    $("body>.toast").remove()
    $toast = $ "<div>",
        class: "toast toast-#{level}"
    $content = $ "<div>",
        class: "toast-content",
        html: message
    $toast.html $content
    $toast.fadeIn(120).appendTo $("body")

    toastTime = setTimeout (-> $toast.fadeOut(200).remove()), time

window.toastError = (message, time)->
    toast(message, "error", time = 3000)
window.toastInfo = (message, time)->
    toast(message, "info", time = 3000)
window.toastWarning = (message, time)->
    toast(message, "warning", time = 3000)